<template>
  <div class="UploadWork">
    <dv-border-box-8 style="padding-top: 15px">
      <dv-decoration-7 style="width: 100%; height: 30px"
        >每日作品上传数量</dv-decoration-7
      >
      <div id="UploadWork" style="height: 350px; width: 100%"></div>
    </dv-border-box-8>
  </div>
</template>

<script>
import { getUploadWork } from "@/api/visualization.js";
export default {
  name: "UploadWork",
  data() {
    return {
      UploadWorkData: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      getUploadWork().then((res) => {
        console.log(res.data);
        this.UploadWorkData = res.data;
        this.initEchart();
      });
    },
    initEchart() {
      let myChart6 = this.$echarts.init(document.getElementById("UploadWork"));
      let option6 = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
        },
        toolbox: {
          show: true,
          feature: {
            saveAsImage: {},
          },
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          axisLine: {
            lineStyle: {
              color: "#ffffff",
            },
          },
          data: this.UploadWorkData.map(item => item.time), // 时间数据作为 X 轴的数据
        },
        yAxis: {
          name: "作品数量",
          type: "value",
          axisLine: {
            lineStyle: {
              color: "#ffffff",
            },
          },
          axisLabel: {
            formatter: "{value} 个",
          },
          axisPointer: {
            snap: true,
          },
        },

        series: [
          {
            name: "作品数量",
            type: "line",
            smooth: true,
            data: this.UploadWorkData.map(item => item.artwork_count), // 作品数量数据作为 Y 轴的数据
          },
        ],
      };

      option6 && myChart6.setOption(option6);
    },
  },
};
</script>

<style></style>
